package com.simulation.superlotto.MN;

import com.simulation.superlotto.SuperlottoApplication;
import com.simulation.superlotto.common.utils.SpringContextUtil;
import com.simulation.superlotto.model.Contrast;
import com.simulation.superlotto.model.Superlotto;
import com.simulation.superlotto.model.User;
import com.simulation.superlotto.service.SuperlottoService;
import javafx.application.Application;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.Scanner;

/**
 * @author ：黄坤
 * @date ：创建于 2020/11/30
 * @description ：
 * @version: 1.0
 */
@Component
public class TestDaLeTou {
    @Autowired
    private static SuperlottoService superlottoService;
    /**
     * 单机版本 模拟机选购买
     * @param args
     */
    public static void main(String[] args) {
        SpringApplication.run(SuperlottoApplication.class,args);
        ApplicationContext applicationContext = SpringContextUtil.getApplicationContext();
        superlottoService = applicationContext.getBean(SuperlottoService.class);
        Scanner sc = new Scanner(System.in);
        s1(sc);
        System.out.println(111);
    }


    public static void s1( Scanner sc){
        System.out.println("模拟投注功能已开启");
        System.out.println("请输入用户名");
        String next = sc.next();
        //进行校验 是否有该用户
        User user = superlottoService.selectUser(next);
        while (StringUtils.isEmpty(user)){
            System.out.println("未存在该用户,是否创建该用户?Y/N");
            String next1 = sc.next();
            if (next1.equalsIgnoreCase("Y")){
                  //创建用户
            }else if(next1.equalsIgnoreCase("N")) {
                 // 退出
            }else {
                System.out.println("命令不符合");
            }
        }
        System.out.println("请输入购买的注数");
        int i = sc.nextInt();
        Superlotto superlotto =  superlottoService.superlotto(i);
        List<Contrast> list = superlotto.getList();
        System.out.println("开始打印彩票......");
        System.out.println("开始打印彩票......");
        System.out.println("开始打印彩票......");
        list.forEach(item->{
            System.out.println(item.getRedBall()+","+item.getBlueBall());
        });
        System.out.println("花费"+list.size()*2+"元");
    }


}
